import app from './app.js';
import {
  readFile
} from 'node:fs/promises';
import bodyParser from 'body-parser'
import userInit from './services/user.js';
import roleInit from './services/role.js';

// 使用body-parser中间件解析请求体
app.use(bodyParser.json()); // 解析JSON格式的请求体
app.use(bodyParser.urlencoded({ extended: true })); // 解析URL编码的请求体
 
app.get('/user-docs', async (_, res) => {
  const file = await readFile(`${process.cwd()}/docs/userDoc.html`, {})

  res.send(file.toString())
})
userInit();
roleInit();

app.listen(3000, () => console.log('Started on http://localhost:3000'))